package com.ruoyi.project.system.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
import com.ruoyi.project.system.domain.SysDoctor;
import com.ruoyi.project.system.service.ISysDoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/system/doctor")
@Anonymous
public class SysDoctorController extends BaseController {

    @Autowired
    private ISysDoctorService doctorService;

    /** 初始加载：查询所有医生 */
    @GetMapping("/all")
    public AjaxResult selectAllDoctor() {
        List<SysDoctor> doctorList = doctorService.selectAllDoctor();
        return success(doctorList); // 返回格式：{code:200, data:[...]}
    }

    /** 按二级科室筛选医生（前端点击二级科室时调用） */
    @GetMapping("/dept/{department}")
    public AjaxResult selectDoctorByDept(@PathVariable String department) {
        List<SysDoctor> doctorList = doctorService.selectDoctorByDept(department);
        return success(doctorList);
    }
}